<template>
	<view>
		<view class="banner">
			<swiper class="swiper" circular='true' indicator-dots="true" autoplay="true" interval="3500" duration="500">
				<swiper-item v-for="item in info.images">
					<image :src="item" class="imgag_banner" mode="aspectFill"></image>
				</swiper-item>
			</swiper>
		</view>

		<view class="goodinfo">
			<view style="height: 30rpx;"></view>
			<view class="goodinfo1">
				{{info.name}}
			</view>
			<view style="height: 20rpx;"></view>
			<view class="good_mi" v-if="show==1">
				<view class="good_mi1"> ¥ {{info.money}} </view>
				<view class="good_mi2"> {{info.property==1?'个人':'企业'}} </view>
			</view>
			<view class="good_mi">
				<view class="good_see1"> 浏览量 {{info.seecount}} </view>
				<view class="good_see1"> 更新时间 {{info.times}} </view>
			</view>



			<view style="height: 20rpx;"></view>
		</view>

		<view class="lines"></view>


		<view class="canshu"  >

			<view class="canshu_tit">基本参数</view>

			<view class="canshuli">
				<view class="canshulia">土地面积</view>
				<view class="canshulib"> {{info.ares}} {{info.ares_status==1?'平方':'亩'}} </view>
			</view>

			<view class="canshuli">
				<view class="canshulia">转让费</view>
				<view class="canshulib"> {{info.makeover}} </view>
			</view>

			<view class="canshuli">
				<view class="canshulia">时长类型</view>
				<view class="canshulib"> {{info.duration==1?'短期':'长期'}} </view>
			</view>

			<view class="canshuli">
				<view class="canshulia">地主名称</view>
				<view class="canshulib"> {{a==0?'**':info.landlord}} </view>
			</view>

			<view class="canshuli">
				<view class="canshulia">地主电话</view>
				<view class="canshulib"> {{a==0?info.mobile_v:info.mobile_v}} </view>
			</view>

			<view class="canshuli">
				<view class="canshulia">地址</view>
				<view class="canshulib"> {{a==0?'**':info.address}} </view>
			</view>

			<view class="canshuli">
				<view class="canshulia">产权</view>
				<view class="canshulib"> {{info.property==1?'个人':'企业'}} </view>
			</view>

			<view class="canshuli">
				<view class="canshulia">用途</view>
				<view class="canshulib"> {{info.extensive}} </view>
			</view>

			<view class="canshuli">
				<view class="canshulia">流转年限</view>
				<view class="canshulib"> {{info.year}} </view>
			</view>

			<view class="canshuli">
				<view class="canshulia">是否核实</view>
				<view class="canshulib"> {{info.see==1?'已核实':'未核实'}} </view>
			</view>
			<view class="canshuli">
				<view class="canshulia">简介</view>
				<view class="canshulib"> </view>
			</view>

			<view class="canshulis">
				{{info.desc}}
			</view>


		</view>

		<view style="height: 140rpx;"></view>

		<view class="bottom">

			<view class="bottomin">

				<view class="bottomin1" @tap="gohoume">
					<view class="bottomin1_1">
						<text class="icon-shouye1 iconfont"></text>
					</view>
					<view class="bottomin1_2">首页</view>
				</view>

				<view class="bottomin1" @tap="ilikethis">
					<view class="bottomin1_1">
						<text class="icon-shoucang iconfont" v-if="like!=1"></text>

						<text class="icon-shoucang reds iconfont" v-if="like==1"></text>
					</view>
					<view class="bottomin1_2  reds" v-if="like==1">收藏</view>
					<view class="bottomin1_2  " v-if="like!=1">收藏</view>
				</view>

				<view class="bottomin2" v-if="a==1" @tap="makphone">拨打电话</view>
				<view class="bottomin3" v-if="a==0 && show==1">

					<view class="bottomin31" @tap="buybuybuy">单次购买</view>
					<view class="bottomin32" @tap="buyviper">购买会员</view>
				</view>
			</view>

		</view>

	</view>
</template>

<script>
	import {
		curl
	} from 'common/api.js';
	export default {
		data() {
			return {
						show:0,
				a: 0,
				info: '',
				like: 0,
				image: '',
				osname:''
			}
		},
		onShareAppMessage(res) {
				let that = this
					let data = {
						title:'办桶沟', // 默认是小程序的名称
						path: '/pages/index/index', // 页面路径，默认是当前页面，必须是以‘/’开头的完整路径
						imageUrl: '', // 图片封面，本地文件路径、网络图片路，支持PNG及JPG，默认当前页面截图，显示图片长宽比是 5:4。
						success: res => {
							
						},
						fail: res => {
						
						},
						complete: res => {}
					  }
					  return data
		},
		onShareTimeline(options) {
				let that = this
				let data = {
					title:'办桶沟', // 默认是小程序的名称
					path: '/pages/index/index', // 页面路径，默认是当前页面，必须是以‘/’开头的完整路径
					imageUrl: '', // 图片封面，本地文件路径、网络图片路，支持PNG及JPG，默认当前页面截图，显示图片长宽比是 5:4。
					success: res => {
						
					},
					fail: res => {
					
					},
					complete: res => {}
				  }
				  return data
				
			},
		onLoad(ret) {

			var that = this;

			var xt= uni.getSystemInfoSync().osName;

			that.osname=xt;
			
			console.log('**********',xt);

			curl('index/getinfobyid', {
				id: ret.id
			}).then((res) => {
				console.log('详情', res.data);
				that.info = res.data;
				that.a = res.data.show;
				that.id = res.data.id;
				that.like = res.data.sc;

			});
			
			
			curl('member/getinfobyid', {
				id: ret.id
			}).then((res) => {
				console.log('详情', res.data);
				that.info = res.data;
				that.a = res.data.show;
				that.id = res.data.id;
				that.like = res.data.sc;
			
			});
			
			wx.showShareMenu({
				withShareTicket:true,
				menus:["shareAppMessage","shareTimeline"]
			})
		},
		onShow() {
			var that=this;
			curl('index/getshow', {}).then((res) => {
				that.show=res.data.show;
			});
		},
			
		methods: {
		
			buyviper() {
				uni.navigateTo({
					url: "/pages/member/viper"
				})
			},

			ilikethis() {
				var id = this.id;
				var that = this;

				curl('member/scland', {
					id: id
				}).then((res) => {
					console.log('详情', res.data);
					that.like = res.data;

				});

			},

			buybuybuy() {
				var id = this.id;
				var that = this;
				var xt=this.osname;
				
				
				
				//#ifdef MP-TOUTIAO 
				
				if (xt=='ios') {
					
					uni.showToast({
						title:'当前系统无法支付',
						icon:'none'
					})
					
					return false;
				}	
				
				
				curl('ttink/paysone', {
					id: id
				}).then((res) => {
					console.log('详情', res.data);

					var orderString = res.data.data;

					uni.requestPayment({
						provider: uni.getStorageSync('providerpayment'),
						// #ifdef MP-TOUTIAO
						orderInfo: orderString,
						service: 5,
						// #endif

						success: function(value) {
							console.log('==== uni.requestPayment success', value);
							let code = value.code
							switch (code) {
								case 0:
									uni.showToast({
										title: '支付成功',
										icon: 'none'
									});
									that.a = 1;
									break;

							}

						},
						fail: function(err) {
							console.log('==== uni.requestPayment err', err);
							uni.showToast({
								title: '支付失败',
								icon: 'none'
							})
							uni.navigateBack({
								delta: 1
							});
						}
					})

				})

				//#endif


				//#ifdef  MP-WEIXIN
				curl('wxpay/paysone', {
					id: id
				}).then((res) => {
					console.log('详情', res.data);

					let orderInfo = {
						"timeStamp": res.data.timeStamp,
						"nonceStr": res.data.nonceStr,
						"package": res.data.package,
						"signType": res.data.signType,
						"paySign": res.data.paySign
					}

					console.log(orderInfo);

					uni.requestPayment({
						provider: 'wxpay',
						timeStamp: res.data.timeStamp,
						nonceStr: res.data.nonceStr,
						package: res.data.package,
						signType: 'MD5',
						paySign: res.data.paySign,
						success: (res) => {
							// 支付成功，改变订单状态
							that.a = 1;
						},
						fail: (err) => {
							console.log(err.errMsg)
							uni.showToast({
								title: '支付失败',
								'icon': 'none'
							})
						}
					})

				});

				//#endif




			},


			gohoume() {
				uni.switchTab({
					url: "/pages/index/index"
				})
			},

			makphone() {
				var a = this.a;
				var that = this;
				var info = this.info;
				var mobile = info.landlordmobile;

				if (a == 1) {
					uni.makePhoneCall({
						phoneNumber: mobile
					})

				} else {

					uni.showModal({
						title: '温馨提示',
						content: '您当前无权限查看!是否立即购买权限?',
						success: function(res) {
							if (res.confirm) {
								that.buybuybuy();
							}
						}
					})

				}



			}
		}
	}
</script>

<style>
	.bottomin31,
	.bottomin32 {
		width: 200rpx;
		height: 60rpx;
		background: #0ab05a;
		text-align: center;
		line-height: 60rpx;
		border-radius: 60rpx;
		color: #ffffff;
		font-size: 28rpx;
	}

	.bottomin3 {
		width: 440rpx;
		height: 80rpx;
		display: flex;
		align-items: center;
		justify-content: space-around;
	}

	.reds {
		color: #e8520d !important;
	}

	.bottomin1_1>text {
		color: #666666;
	}

	.canshu_none {
		width: 710rpx;
		height: 100rpx;
		margin: auto;
		margin: auto;
		text-align: center;
		line-height: 100rpx;
		color: #747474;
		font-size: 28rpx;
	}

	.canshulib {
		font-size: 30rpx;
		color: #333333;
	}

	.canshulia {
		font-size: 30rpx;
		color: #747474;
	}

	.canshulis {
		width: 710rpx;
		height: auto;
		margin: auto;
		lin-height: 40rpx;
		font-size: 28rpx;
		color: #333333;
	}

	.canshuli {
		width: 710rpx;
		height: 80rpx;
		margin: auto;
		display: flex;
		align-items: center;
		justify-content: space-between;
	}

	.canshu_tit {
		width: 710rpx;
		height: 80rpx;
		line-height: 100rpx;
		color: #0ab05a;
		margin: auto;
		font-weight: 600;
		font-size: 30rpx;
	}

	.bottomin2 {
		width: 440rpx;
		background: #0ab05a;
		height: 80rpx;
		border-radius: 80rpx;
		text-align: center;
		line-height: 80rpx;
		font-weight: 500;
		color: #ffffff;
	}

	.bottomin1_2 {
		height: 45rpx;
		width: 120rpx;
		color: #666666;
		text-align: center;
		line-height: 45rpx;
		font-size: 24rpx;
	}

	.bottomin1_1 {
		height: 45rpx;
		width: 120rpx;
		text-align: center;
	}

	.bottomin1 {
		width: 130rpx;
		height: 90rpx;
		text-align: center;
	}

	.bottomin {
		width: 710rpx;
		height: 100rpx;
		margin: auto;
		display: flex;
		align-items: center;
		justify-content: space-around;
	}

	.bottom {
		width: 100%;
		height: 100rpx;
		background: #ffffff;
		position: fixed;
		bottom: 0px;
		z-index: 999;
	}

	.good_see1 {
		color: #666666;
		font-weight: 500;
		font-size: 28rpx;
	}

	.good_mi2 {
		color: #e8520d;
		font-weight: bold;
		font-size: 32rpx;
	}

	.good_mi1 {
		color: #e8520d;
		font-weight: bold;
		font-size: 32rpx;
	}

	.good_mi {
		width: 710rpx;
		height: 70rpx;
		margin: auto;
		display: flex;
		align-items: center;
		justify-content: space-between;
	}

	.lines {
		width: 100%;
		height: 50rpx;
		background: #fafafa;
	}

	.goodinfo1 {
		width: 710rpx;
		height: auto;
		margin: auto;
		font-size: 32rpx;
		font-weight: 600;
	}

	.goodinfo {
		width: 100%;
		height: auto;
		background: #ffffff;
	}

	.imgag_banner {
		width: 750rpx !important;
		height: 500rpx !important;
	}

	swiper {
		width: 750rpx;
		height: 500rpx !important;
	}

	.banner {
		width: 750rpx;
		height: 500rpx;
	}
</style>